package com.photographysharing.interceptor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 注册自定义拦截器
 */

@Configuration
public class Interceptor implements WebMvcConfigurer {

    @Bean
    public RoleInterceptor getRoleInterceptor() {
        return new RoleInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加角色拦截器
        registry.addInterceptor(getRoleInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/files/**","/files/shows/**");
    }
}
